//显示产品列表和详细
const express = require("express");
let indexRouter = express.Router();
let pData = require("../data/product.json");
// console.log(pData);
indexRouter.get("/productlist", (req, res) => {
  res.render("productlist.ejs", { pData });
});
indexRouter.get("/productDetail", (req, res) => {
  //接受产品的id 通过id查找详细信息
  let { id } = req.query;
  let detailData = pData.find((item) => item.id == id);
  res.render("productDetail.ejs", { detailData });
});
module.exports = indexRouter;
